/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session02;

/**
 *
 * @author macbookpro
 */
public class Account {

    private String accountCode;
    private double balance;

    public Account() {
    }

    public Account(String accountCode, double balance) {
        this.accountCode = accountCode;
        this.balance = balance;
    }

    public String getAccountCode() {
        return accountCode;
    }

    public void setAccountCode(String accountCode) {
        this.accountCode = accountCode;
    }

    public double getBalance() {
        return balance;
    }

    public boolean withdraw(double balance) {
        if (balance <= 0 || this.balance - balance <= 0) {
            return false;
        }
        this.balance -= balance;
        return true;
    }

    public boolean deposit(double dep) {
        if (dep <= 0) {
            return false;
        }
        this.balance += dep;
        return true;
    }

    public String toString() {
        return "Balance: " + balance;
    }
}
